var vue = new Vue({
    el:'#mycheckOrderApp',
    data:{

        orderTailList:[],  //订单跟踪对象数组
        orderNo:'',  //查询的订单号
        orderOdd:'',  //查询后显示的订单号
        orderNos:[],  //最近查询订单号数组
        resultOrderNo:'',  //查询结果的订单号显示
    },
    mounted:function () {


    },
    methods:{
        //获取订单跟踪对象
        queryOrderTail:function () {

            var it = this;

            if (it.orderNo.length != 16){

                $.toast({
                    title: '信息提示框',
                    subtitle: '6秒后自动关闭',
                    content: '请输入正确的运单号',
                    type: 'info',
                    delay: 6000,
                    pause_on_hover: false
                });
                return false;

            }

            if (it.orderNo.substring(0,2) != 'NF'){
                $.toast({
                    title: '信息提示框',
                    subtitle: '6秒后自动关闭',
                    content: '请输入正确的运单号',
                    type: 'info',
                    delay: 6000,
                    pause_on_hover: false
                });
                return false;
            }

            axios({
                url:'/logistics/customer/queryOrderTailByOrderNo?orderNo='+it.orderNo,
                method:'get'
            }).then(function (res) {
                if (res.data.code == 200){
                    it.orderOdd = it.orderNo;
                    it.resultOrderNo = it.orderNo;

                }
                it.orderTailList = res.data.data;
                //把查询成功的订单存入
                if(res.data.data !=null && res.data.data.length > 0){
                    if (it.orderNos.length == 0){
                        it.orderNos.push(it.orderNo);
                    }else{

                        for (var i=0;i<it.orderNos.length;i++){
                            console.log(it.orderNo+"-------"+it.orderNos[i])
                            if (it.orderNo != it.orderNos[i]){

                                it.orderNos.push(it.orderNo);
                            }
                        }


                    }





                }

            }).catch(function (error) {

                console.log("出错啦")

            })

        },
        //清空查询订单号文本框
        resetOrderNo:function () {

            this.orderNo = "";

        },
        //移除最近查询的订单号
        removeOrderNos:function (index) {

            if (index != -1){
                this.orderNos.splice(index,1);
            }


        }
    }


})
